home *** CD-ROM | disk | FTP | other *** search
/ Garbo / Garbo.cdr / mac / hypercrd / hc1_2_x / inptmthd.sit / Input Methods / card_9755.txt < prev    next >
Text File  |  1989-11-24  |  15KB  |  608 lines

  1. -- card: 9755 from stack: in
  2. -- bmap block id: 10047
  3. -- flags: 0000
  4. -- background id: 2696
  5. -- name: Match Key Objects
  6. ----- HyperTalk script -----
  7. -- This card is for matching sets of words to key words
  8. -- For example, matching words that rhyme with the key word
  9. -- Each key word has a "bucket" that the matching words go into
  10. -- The nifty part is that you can change it to use your own words
  11. --
  12. -- Setting up the key words and matching words is simple:
  13. --   1) type "author" into the message box (a field and a button named
  14. --      "Process" will appear)
  15. --   2) on separate lines in the field, put a key word, followed by the
  16. --      matching words, each separated by a comma
  17. --   3) click the "Process" button
  18. --
  19. -- For example, to set up a simple ryhming exercise with frog and
  20. -- cat as the key words, you would type
  21. --   frog,dog,log
  22. --   cat,sat,mat,hat
  23. --
  24. -- You can actually use more than one word as a "word", but you may
  25. -- have to change the fWidth variable in the process script to make
  26. -- the word fields bigger.
  27.  
  28.  
  29. -- created by Jim Taylor  4/27/89
  30. -- Microcomputer Support for Curriculum
  31. -- 101 HRCB, Brigham Young University, Provo, UT 84602
  32. -- taylorj@byuvax.bitnet
  33. --
  34. -- This code has been released into the public domain.
  35.  
  36.  
  37. on openCard
  38.   global numRight
  39.   put 0 into numRight
  40.   pass openCard
  41. end openCard
  42.  
  43. -- Clean things up if anything was done
  44. on closeCard
  45.   global numRight
  46.   if numRight > 0 then cleanUp
  47.   pass closeCard
  48. end closeCard
  49.  
  50. -- Empty the buckets, unhide all the words, and reset the score
  51. on cleanUp
  52.   global numRight
  53.   lock screen
  54.   repeat with n = 1 to the number of lines in card field "Table"
  55.     put "Bucket" && n into fName
  56.     put empty into card field fName
  57.   end repeat
  58.   repeat with n = 1 to card field "numWords"
  59.     put "Word" && n into wfName
  60.     show card field wfName
  61.   end repeat
  62.   put 0 into numRight
  63. end cleanUp
  64.  
  65.  
  66. on author
  67.   show button "Process"
  68.   show card field "Table"
  69.   select card field "Table"
  70.   type "+" with commandKey, shiftKey  -- bring the field to the front
  71.   choose browse tool
  72. end author
  73.  
  74.  
  75. on mouseDown
  76.   get the short name of the target
  77.   if word 1 of it is "Word" then moveWord
  78. end mouseDown
  79.  
  80.  
  81. -- Let the user move the selected word's field.  If he puts it in the
  82. -- right bucket, add the word to the bucket and hide the field.
  83. on moveWord
  84.   global numRight
  85.   put the loc of the target into startLoc
  86.   repeat until the mouse is up
  87.     show the target at the mouseLoc
  88.   end repeat
  89.   put the mouseLoc into endLoc
  90.   -- surround word by commas to prevent spurious matches
  91.   put "," & target & "," into theWord
  92.   -- go through the table to see if the word is in the right bucket
  93.   repeat with n = 1 to the number of lines in card field "Table"
  94.     if theWord is in line n of card field "Table" then
  95.       put "Bucket" && n into fName
  96.       if endLoc is within the rect of card field fName then  -- correct
  97.         hide the target
  98.         -- add the word to the bucket
  99.         if card field fName is empty then
  100.           put target into card field fName
  101.         else
  102.           put " - " & target after card field fName
  103.         end if
  104.         -- update the score and see if all done
  105.         add 1 to numRight
  106.         if numRight = card field "NumWords" then  -- all correct!
  107.           rightSound
  108.           -- cleanUp  -- (if you want to let them do it again)
  109.         end if
  110.       end if
  111.       exit repeat
  112.     end if
  113.   end repeat
  114.   set the loc of the target to startLoc  -- put the word's field back
  115. end moveWord
  116.  
  117.  
  118.  
  119.  
  120. -- part 2 (button)
  121. -- low flags: 80
  122. -- high flags: A003
  123. -- rect: left=325 top=312 right=334 bottom=425
  124. -- title width / last selected line: 0
  125. -- icon id / first selected line: 0 / 0
  126. -- text alignment: 1
  127. -- font id: 0
  128. -- text size: 12
  129. -- style flags: 0
  130. -- line height: 16
  131. -- part name: Process
  132. ----- HyperTalk script -----
  133. -- Go through the table, building new key fields, bucket fields, and
  134. -- word fields.
  135.  
  136. on mouseUp
  137.   global list
  138.   hide card field "Table"
  139.   -- lock screen  -- uncomment to speed things up
  140.  
  141.   -- delete old fields
  142.   repeat with f = the number of card fields down to 1
  143.     if word 1 of the short name of card field f is in "Word Key Bucket" then
  144.       show card field f
  145.       select card field f
  146.       doMenu "Clear Field"
  147.     end if
  148.   end repeat
  149.  
  150.   -- get rid of blank lines at end of field
  151.   repeat until last line of card field "Table" is not empty
  152.     delete last line of card field "Table"
  153.     if card field "Table" is empty then
  154.       beep
  155.       exit mouseUp
  156.     end if
  157.   end repeat
  158.  
  159.   -- make keys and buckets for each line in the table, and put the
  160.   -- words into a master list
  161.   put 18 into fHeight  -- height of key & bucket fields
  162.   put 70 into fWidth  -- width of key fields
  163.   put 22 into fSpace  -- spacing of key & bucket fields
  164.   put 80 into starty  -- topmost starting location of fields
  165.   put 350 into startx  -- leftmost starting location of word fields
  166.   put empty into list
  167.   repeat with n = 1 to the number of lines in card field "Table"
  168.     put line n of card field "Table" into theLine
  169.     -- remove spaces after items
  170.     put offset(", ", theLine) into i
  171.     repeat until i = 0
  172.       delete char i+1 of theLine
  173.       put offset(", ", theLine) into i
  174.     end repeat
  175.     -- make sure each line has a trailing comma
  176.     if last char of theLine Γëá "," then put "," after theLine
  177.     -- remove spaces before items
  178.     put offset(" ,", theLine) into i
  179.     repeat until i = 0
  180.       delete char i of theLine
  181.       put offset(" ,", theLine) into i
  182.     end repeat
  183.     -- put the cleaned up line back in the table
  184.     put theLine into line n of card field "Table"
  185.     -- add words to master list
  186.     put the number of items in theLine into lastItem
  187.     put item 2 to lastItem of theLine & "," after list
  188.  
  189.     -- make key fields and bucket fields
  190.     put (n-1)*fSpace+starty into y
  191.     doMenu "New Field"
  192.     set the rect of last card field to 0,y,fWidth,y+fHeight
  193.     set the name of last card field to "Key" && n
  194.     set the lockText of last card field to true
  195.     set the textStyle of last card field to bold
  196.     set the textAlign of last card field to right
  197.     put item 1 of theLine into last card field
  198.     doMenu "New Field"
  199.     set the rect of last card field to fwidth+2,y,startx-10,y+fHeight
  200.     set the name of last card field to "Bucket" && n
  201.     set the style of last card field to rectangle
  202.     set the lockText of last card field to true
  203.   end repeat
  204.   -- permanently remember the number of words
  205.   put the number of items in list into card field "NumWords"
  206.  
  207.   -- randomly remove words from the master list and put them in fields
  208.   put 17 into fHeight  -- height of word fields
  209.   put 54 into fWidth  -- width of word fields
  210.   put startx into x
  211.   put starty into y
  212.   repeat with w = 1 to card field "NumWords"
  213.     put random(number of items in list) into itemNum
  214.     put item itemNum of list into theWord
  215.     delete item itemNum of list
  216.     doMenu "New Field"
  217.     set the textAlign of last card field to center
  218.     set the lockText of last card field to true
  219.     set the rect of last card field to x,y,x+fWidth,y+fHeight
  220.     set the name of last card field to "Word" && w
  221.     put theWord into last card field
  222.     add fWidth to x
  223.     if x > 512-fWidth then
  224.       put startx into x
  225.       add fHeight to y
  226.     end if
  227.   end repeat
  228.  
  229.   hide me
  230.   choose browse tool
  231. end mouseUp
  232.  
  233.  
  234.  
  235. -- part 9 (field)
  236. -- low flags: 81
  237. -- high flags: 0000
  238. -- rect: left=0 top=0 right=21 bottom=43
  239. -- title width / last selected line: 0
  240. -- icon id / first selected line: 0 / 0
  241. -- text alignment: 0
  242. -- font id: 3
  243. -- text size: 12
  244. -- style flags: 0
  245. -- line height: 16
  246. -- part name: NumWords
  247.  
  248.  
  249. -- part 27 (field)
  250. -- low flags: 01
  251. -- high flags: 2002
  252. -- rect: left=87 top=208 right=277 bottom=433
  253. -- title width / last selected line: 0
  254. -- icon id / first selected line: 0 / 0
  255. -- text alignment: 0
  256. -- font id: 3
  257. -- text size: 12
  258. -- style flags: 0
  259. -- line height: 16
  260. -- part name: 
  261.  
  262.  
  263. -- part 1 (field)
  264. -- low flags: 80
  265. -- high flags: 0004
  266. -- rect: left=32 top=64 right=297 bottom=386
  267. -- title width / last selected line: 0
  268. -- icon id / first selected line: 0 / 0
  269. -- text alignment: 0
  270. -- font id: 3
  271. -- text size: 12
  272. -- style flags: 0
  273. -- line height: 16
  274. -- part name: Table
  275.  
  276.  
  277. -- part 259 (field)
  278. -- low flags: 01
  279. -- high flags: 0000
  280. -- rect: left=0 top=80 right=98 bottom=70
  281. -- title width / last selected line: 0
  282. -- icon id / first selected line: 0 / 0
  283. -- text alignment: 65535
  284. -- font id: 3
  285. -- text size: 12
  286. -- style flags: 256
  287. -- line height: 16
  288. -- part name: Key 1
  289.  
  290.  
  291. -- part 260 (field)
  292. -- low flags: 01
  293. -- high flags: 0002
  294. -- rect: left=72 top=80 right=98 bottom=340
  295. -- title width / last selected line: 0
  296. -- icon id / first selected line: 0 / 0
  297. -- text alignment: 0
  298. -- font id: 3
  299. -- text size: 12
  300. -- style flags: 0
  301. -- line height: 16
  302. -- part name: Bucket 1
  303.  
  304.  
  305. -- part 261 (field)
  306. -- low flags: 01
  307. -- high flags: 0000
  308. -- rect: left=0 top=102 right=120 bottom=70
  309. -- title width / last selected line: 0
  310. -- icon id / first selected line: 0 / 0
  311. -- text alignment: 65535
  312. -- font id: 3
  313. -- text size: 12
  314. -- style flags: 256
  315. -- line height: 16
  316. -- part name: Key 2
  317.  
  318.  
  319. -- part 262 (field)
  320. -- low flags: 01
  321. -- high flags: 0002
  322. -- rect: left=72 top=102 right=120 bottom=340
  323. -- title width / last selected line: 0
  324. -- icon id / first selected line: 0 / 0
  325. -- text alignment: 0
  326. -- font id: 3
  327. -- text size: 12
  328. -- style flags: 0
  329. -- line height: 16
  330. -- part name: Bucket 2
  331.  
  332.  
  333. -- part 263 (field)
  334. -- low flags: 01
  335. -- high flags: 0000
  336. -- rect: left=0 top=124 right=142 bottom=70
  337. -- title width / last selected line: 0
  338. -- icon id / first selected line: 0 / 0
  339. -- text alignment: 65535
  340. -- font id: 3
  341. -- text size: 12
  342. -- style flags: 256
  343. -- line height: 16
  344. -- part name: Key 3
  345.  
  346.  
  347. -- part 264 (field)
  348. -- low flags: 01
  349. -- high flags: 0002
  350. -- rect: left=72 top=124 right=142 bottom=340
  351. -- title width / last selected line: 0
  352. -- icon id / first selected line: 0 / 0
  353. -- text alignment: 0
  354. -- font id: 3
  355. -- text size: 12
  356. -- style flags: 0
  357. -- line height: 16
  358. -- part name: Bucket 3
  359.  
  360.  
  361. -- part 265 (field)
  362. -- low flags: 01
  363. -- high flags: 0000
  364. -- rect: left=350 top=80 right=97 bottom=404
  365. -- title width / last selected line: 0
  366. -- icon id / first selected line: 0 / 0
  367. -- text alignment: 1
  368. -- font id: 3
  369. -- text size: 12
  370. -- style flags: 0
  371. -- line height: 16
  372. -- part name: Word 1
  373.  
  374.  
  375. -- part 266 (field)
  376. -- low flags: 01
  377. -- high flags: 0000
  378. -- rect: left=404 top=80 right=97 bottom=458
  379. -- title width / last selected line: 0
  380. -- icon id / first selected line: 0 / 0
  381. -- text alignment: 1
  382. -- font id: 3
  383. -- text size: 12
  384. -- style flags: 0
  385. -- line height: 16
  386. -- part name: Word 2
  387.  
  388.  
  389. -- part 267 (field)
  390. -- low flags: 01
  391. -- high flags: 0000
  392. -- rect: left=458 top=80 right=97 bottom=512
  393. -- title width / last selected line: 0
  394. -- icon id / first selected line: 0 / 0
  395. -- text alignment: 1
  396. -- font id: 3
  397. -- text size: 12
  398. -- style flags: 0
  399. -- line height: 16
  400. -- part name: Word 3
  401.  
  402.  
  403. -- part 268 (field)
  404. -- low flags: 01
  405. -- high flags: 0000
  406. -- rect: left=350 top=97 right=114 bottom=404
  407. -- title width / last selected line: 0
  408. -- icon id / first selected line: 0 / 0
  409. -- text alignment: 1
  410. -- font id: 3
  411. -- text size: 12
  412. -- style flags: 0
  413. -- line height: 16
  414. -- part name: Word 4
  415.  
  416.  
  417. -- part 269 (field)
  418. -- low flags: 01
  419. -- high flags: 0000
  420. -- rect: left=404 top=97 right=114 bottom=458
  421. -- title width / last selected line: 0
  422. -- icon id / first selected line: 0 / 0
  423. -- text alignment: 1
  424. -- font id: 3
  425. -- text size: 12
  426. -- style flags: 0
  427. -- line height: 16
  428. -- part name: Word 5
  429.  
  430.  
  431. -- part 270 (field)
  432. -- low flags: 01
  433. -- high flags: 0000
  434. -- rect: left=458 top=97 right=114 bottom=512
  435. -- title width / last selected line: 0
  436. -- icon id / first selected line: 0 / 0
  437. -- text alignment: 1
  438. -- font id: 3
  439. -- text size: 12
  440. -- style flags: 0
  441. -- line height: 16
  442. -- part name: Word 6
  443.  
  444.  
  445. -- part 271 (field)
  446. -- low flags: 01
  447. -- high flags: 0000
  448. -- rect: left=350 top=114 right=131 bottom=404
  449. -- title width / last selected line: 0
  450. -- icon id / first selected line: 0 / 0
  451. -- text alignment: 1
  452. -- font id: 3
  453. -- text size: 12
  454. -- style flags: 0
  455. -- line height: 16
  456. -- part name: Word 7
  457.  
  458.  
  459. -- part 272 (field)
  460. -- low flags: 01
  461. -- high flags: 0000
  462. -- rect: left=404 top=114 right=131 bottom=458
  463. -- title width / last selected line: 0
  464. -- icon id / first selected line: 0 / 0
  465. -- text alignment: 1
  466. -- font id: 3
  467. -- text size: 12
  468. -- style flags: 0
  469. -- line height: 16
  470. -- part name: Word 8
  471.  
  472.  
  473. -- part 273 (field)
  474. -- low flags: 01
  475. -- high flags: 0000
  476. -- rect: left=458 top=114 right=131 bottom=512
  477. -- title width / last selected line: 0
  478. -- icon id / first selected line: 0 / 0
  479. -- text alignment: 1
  480. -- font id: 3
  481. -- text size: 12
  482. -- style flags: 0
  483. -- line height: 16
  484. -- part name: Word 9
  485.  
  486.  
  487. -- part 274 (field)
  488. -- low flags: 01
  489. -- high flags: 0000
  490. -- rect: left=350 top=131 right=148 bottom=404
  491. -- title width / last selected line: 0
  492. -- icon id / first selected line: 0 / 0
  493. -- text alignment: 1
  494. -- font id: 3
  495. -- text size: 12
  496. -- style flags: 0
  497. -- line height: 16
  498. -- part name: Word 10
  499.  
  500.  
  501. -- part 275 (field)
  502. -- low flags: 81
  503. -- high flags: 2004
  504. -- rect: left=92 top=152 right=264 bottom=352
  505. -- title width / last selected line: 0
  506. -- icon id / first selected line: 0 / 0
  507. -- text alignment: 0
  508. -- font id: 3
  509. -- text size: 12
  510. -- style flags: 0
  511. -- line height: 16
  512. -- part name: Info
  513. ----- HyperTalk script -----
  514. on mouseUp
  515.   info
  516. end mouseUp
  517.  
  518.  
  519. -- part 276 (button)
  520. -- low flags: 00
  521. -- high flags: 2001
  522. -- rect: left=490 top=320 right=342 bottom=512
  523. -- title width / last selected line: 0
  524. -- icon id / first selected line: 26635 / 26635
  525. -- text alignment: 1
  526. -- font id: 0
  527. -- text size: 12
  528. -- style flags: 0
  529. -- line height: 16
  530. -- part name: 
  531. ----- HyperTalk script -----
  532. on mouseUp
  533.   info
  534. end mouseUp
  535.  
  536.  
  537.  
  538. -- part contents for card part 1
  539. ----- text -----
  540. far,bar,car,jar,par,tar,czar,mar,
  541. cat,sat,fat,
  542. hog,frog,
  543.  
  544. -- part contents for card part 9
  545. ----- text -----
  546. 10
  547.  
  548. -- part contents for card part 27
  549. ----- text -----
  550.  
  551. Drag the words on the right into the boxes next to the words they rhyme with.
  552.  
  553. -- part contents for card part 259
  554. ----- text -----
  555. far
  556.  
  557. -- part contents for card part 261
  558. ----- text -----
  559. cat
  560.  
  561. -- part contents for card part 263
  562. ----- text -----
  563. hog
  564.  
  565. -- part contents for card part 265
  566. ----- text -----
  567. czar
  568.  
  569. -- part contents for card part 266
  570. ----- text -----
  571. car
  572.  
  573. -- part contents for card part 267
  574. ----- text -----
  575. jar
  576.  
  577. -- part contents for card part 268
  578. ----- text -----
  579. par
  580.  
  581. -- part contents for card part 269
  582. ----- text -----
  583. tar
  584.  
  585. -- part contents for card part 270
  586. ----- text -----
  587. sat
  588.  
  589. -- part contents for card part 271
  590. ----- text -----
  591. mar
  592.  
  593. -- part contents for card part 272
  594. ----- text -----
  595. frog
  596.  
  597. -- part contents for card part 273
  598. ----- text -----
  599. bar
  600.  
  601. -- part contents for card part 274
  602. ----- text -----
  603. fat
  604.  
  605. -- part contents for card part 275
  606. ----- text -----
  607.  
  608. This card is designed so you can copy it and easily change the words to fit your needs.  See the card script for details.